<template>
    <view class="container">
        <view class="address">
            <view @tap="__e" class="address-item" :data-event-opts="[['tap', [['selectAddress', ['$event']]]]]" :data-index="index" v-for="(item, index) in $root.l0" :key="index">
                <view class="address-item-fl">
                    <view class="user-info">
                        <text class="user-name">{{ item[$orig].consignee }}</text>
                        <text class="user-phone">{{ item.f0 }}</text>
                    </view>
                    <view class="address-info">{{ '' + item[$orig].province + item[$orig].city + item[$orig].district + item[$orig].address + '' }}</view>
                </view>

                <view @tap.stop.prevent="__e" class="actions" :data-event-opts="[['tap', [['', ['$event']]]]]">
                    <view @tap="__e" class="actions-detele" :data-event-opts="[['tap', [['handleDelete', ['$event']]]]]">
                        <image src="https://img121.7dun.com/yuanqimali/myAddress/deleteIcon.png"></image>
                        删除
                    </view>
                    <view @tap="__e" class="actions-edit" :data-event-opts="[['tap', [['handleEdit', [index]]]]]">
                        <image src="https://img121.7dun.com/yuanqimali/myAddress/editIcon.png"></image>
                        编辑
                    </view>
                </view>
            </view>
            <no-data @__l="__l" title="暂无地址" vueId="5537bcf8-1" v-if="$root.g0"></no-data>
        </view>
        <view class="footer">
            <view @tap="__e" class="footer-button import" :data-event-opts="[['tap', [['handleImportAddress', ['$event']]]]]" hoverClass="hover">
                <text></text>
            </view>
            <view @tap="__e" class="footer-button add" :data-event-opts="[['tap', [['handleNewAddress', ['$event']]]]]" hoverClass="hover">
                <text></text>
            </view>
        </view>
    </view>
</template>

<script>
import noData from '@/components/NoData/NoData';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['pages/myAddress/index'],
    {
        '328f': function (t, e, n) {
            'use strict';

            n.r(e);
            var i = n('b723');
            var s = n('620f');
            for (var a in s) {
                if (['default'].indexOf(a) < 0) {
                    (function (t) {
                        n.d(e, t, function () {
                            return s[t];
                        });
                    })(a);
                }
            }
            n('445e');
            var c = n('f0c5');
            var o = Object(c.a)(s.default, i.b, i.c, false, null, null, null, false, i.a, void 0);
            e.default = o.exports;
        },
        '445e': function (t, e, n) {
            'use strict';

            var i = n('e105');
            n.n(i).a;
        },
        6193: function (t, e, n) {
            'use strict';

            (function (t, e) {
                var i = n('4ea4');
                n('18ba');
                i(n('66fd'));
                var s = i(n('328f'));
                t.__webpack_require_UNI_MP_PLUGIN__ = n;
                e(s.default);
            }.call(this, n('bc2e').default, n('543d').createPage));
        },
        '620f': function (t, e, n) {
            'use strict';

            n.r(e);
            var i = n('fcc7');
            var s = n.n(i);
            for (var a in i) {
                if (['default'].indexOf(a) < 0) {
                    (function (t) {
                        n.d(e, t, function () {
                            return i[t];
                        });
                    })(a);
                }
            }
            e.default = s.a;
        },
        b723: function (t, e, n) {
            'use strict';

            n.d(e, 'b', function () {
                return s;
            });
            n.d(e, 'c', function () {
                return a;
            });
            n.d(e, 'a', function () {
                return i;
            });
            var i = {
                NoData: function () {
                    return n.e('components/NoData/NoData').then(n.bind(null, 'cafe'));
                }
            };
            var s = function () {
                var that = this;
                var e =
                    (that.$createElement,
                    that._self._c,
                    that.__map(that.list, function (e, n) {
                        return {
                            $orig: that.__get_orig(e),
                            f0: that._f('hidePhoneDetail')(e.phone)
                        };
                    }));
                var n = !that.list.length && that.init;
                that.$mp.data = Object.assign(
                    {},
                    {
                        $root: {
                            l0: e,
                            g0: n
                        }
                    }
                );
            };
            var a = [];
        },
        e105: function (t, e, n) {},
        fcc7: function (t, e, n) {
            'use strict';

            (function (t) {
                Object.defineProperty(e, '__esModule', {
                    value: true
                });
                e.default = void 0;
                var i = n('a7b1');
                var s = {
                    components: {
                        NoData: function () {
                            n.e('components/NoData/NoData')
                                .then(
                                    function () {
                                        return resolve(n('cafe'));
                                    }.bind(null, n)
                                )
                                .catch(n.oe);
                        }
                    },
                    data: function () {
                        return {
                            list: [],
                            select: false,
                            init: false
                        };
                    },
                    filters: {
                        hidePhoneDetail: function (t) {
                            return t.substring(0, 3) + '****' + t.substring(7, 11);
                        }
                    },
                    onLoad: function (t) {
                        if (t.select) {
                            this.select = true;
                        }
                    },
                    onShow: function () {
                        var that = this;
                        t.showLoading({
                            title: '加载中'
                        });
                        (0, i.getAddressList)().then(function (n) {
                            that.list = n.data.addresses;
                            that.init = true;
                            t.hideLoading();
                        });
                    },
                    methods: {
                        fetchData: function () {
                            var that = this;
                            (0, i.getAddressList)().then(function (n) {
                                that.list = n.data.addresses;
                                that.init = true;
                                t.hideLoading();
                            });
                        },
                        selectAddress: function (e) {
                            if (this.select) {
                                t.$emit('selectAddress', this.list[e.currentTarget.dataset.index]);
                                t.navigateBack({
                                    delta: 1
                                });
                            }
                        },
                        handleEdit: function (t) {
                            var e = this.list[t];
                            this.$navigator.navigateTo({
                                url:
                                    '/pages/setAddress/index?uuid='.concat(e.uuid) +
                                    '&consignee='.concat(e.consignee) +
                                    '&phone='.concat(e.phone) +
                                    '&province='.concat(e.province) +
                                    '&city='.concat(e.city) +
                                    '&district='.concat(e.district) +
                                    '&address='.concat(e.address) +
                                    '&tag='.concat(e.tag) +
                                    '&is_default='.concat(e.is_default)
                            });
                        },
                        handleDelete: function (e) {
                            var that = this;
                            var s = e.currentTarget.dataset.index;
                            t.showModal({
                                title: '提示',
                                content: '删除该收货地址?',
                                success: function (e) {
                                    if (e.confirm) {
                                        t.showLoading({
                                            title: '加载中'
                                        });
                                        (0, i.deleteAddress)(that.list[s].uuid).then(function (e) {
                                            that.list.splice(s, 1);
                                            t.hideLoading();
                                        });
                                    }
                                }
                            });
                        },
                        handleNewAddress: function () {
                            t.navigateTo({
                                url: '/pages/setAddress/index'
                            });
                        },
                        $getAddress: function (t) {
                            console.log('main get address =======>');
                            my.authorize({
                                scopes: 'scope.addressList',
                                success: function (e) {
                                    my.tb.chooseAddress(
                                        {
                                            addAddress: 'show',
                                            searchAddress: 'hide',
                                            locateAddress: 'hide'
                                        },
                                        function (e) {
                                            if (t.success) {
                                                t.success(e);
                                            }
                                        },
                                        function (e) {
                                            if (t.fail) {
                                                t.fail(e);
                                            }
                                        }
                                    );
                                }
                            });
                        },
                        handleImportAddress: function () {
                            var that = this;
                            t.chooseAddress({
                                success: function (t) {
                                    if (t.error) {
                                        return false;
                                    }
                                    (0, i.createAddress)({
                                        consignee: t.userName,
                                        phone: t.telNumber,
                                        province: t.provinceName,
                                        city: t.cityName,
                                        district: t.countyName,
                                        address: t.detailInfo,
                                        tag: '',
                                        is_default: 0
                                    }).then(function (t) {
                                        that.fetchData();
                                    });
                                }
                            });
                        }
                    }
                };
                e.default = s;
            }.call(this, n('543d').default));
        }
    },
    [['6193', 'common/runtime', 'common/vendor']]
]);
</script>
<style>
@import './index.css';
</style>
